#!/usr/bin/perl

# ------------------------------------------------------------------------------
# --- Use curl to obtain PDB file for PDB ID -----------------------------------
# ------------------------------------------------------------------------------

use strict;
use warnings;

my $pdb = shift;

defined ($pdb) or 
	die "ERROR: Must pass PDB code as input.\n";

print STDERR "Downloading PDB file $pdb...\n";

# Make curl command, like:
# curl -o pdb_files/4HHB.pdb "http://www.rcsb.org/pdb/files/4HHB.pdb"
	
my $curl_cmd = "curl -o pdb_files/" . $pdb . ".pdb ";
$curl_cmd .= "\"http://www.rcsb.org/pdb/files/" . $pdb . ".pdb\";\n";

# Download PDB file
system($curl_cmd);

exit 0;
